import { BaseConfig } from "../Base/BaseConfig";
import { ResManager,RetHander,SaveType } from "../Managers/ResManager";
import { ConstValue } from "../ConstType/ConstValue";

export class SkillData{
    id:number;
    type:number;
    value1:number;
    value2:number;
    describe:string;
}

export class SkillConfig extends BaseConfig{
    private skillData:SkillData[]=[];
    constructor(callback:Function,caller:any,arg:any){
        super();
        ResManager.getInstance()._addLoadingResItem(ConstValue.config_dir+'SkillConfig.txt',cc.Asset,function(ret:RetHander){
            // console.log(ret);
            // cc.log(ret.m_err);
            if(ret.m_err){
                cc.log(ret.m_err);
            }
            else{
                // cc.log(ret.m_data);
                let object:any=ret.m_data[0];
                let encode=object.text;
                let decode=window.atob(encode);
                // cc.log(decode)
                object=JSON.parse(decode);
                for(var i in object){
                    this.skillData[i]=object[i];
                }
                // cc.log(this.skillData);
                if(callback)callback.call(caller,arg);
            }
        }.bind(this),{count:1,saveType:SaveType.UI});
    }
    getSkillData():SkillData[]{
        return this.skillData;
    }
}
